package com.fanyang.study.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/multi")
public class MultiModelController {
    @Resource(name = "deepseekModel")
    private ChatModel deepseekModel;
    @Resource(name = "qwenModel")
    private ChatModel qwenModel;
    @Resource(name = "deepseekChatClient")
    private ChatClient deepseekChatClient;
    @Resource(name = "qwenChatClient")
    private ChatClient qwenChatClient;

    @GetMapping("/stream/chatByDeepseek")
    public Flux<String> streamChatByDeepseek(@RequestParam("msg") String msg) {
        return deepseekModel.stream(msg);
    }

    @GetMapping("/stream/chatByQwen")
    public Flux<String> streamChatByQwen(@RequestParam("msg") String msg) {
        return qwenModel.stream(msg);
    }
    @GetMapping("/stream/chatByDeepseekChatClient ")
    public Flux<String> streamChatByDeepseekChatClient(@RequestParam("msg") String msg) {
        return deepseekChatClient.prompt("你是一位架构师").user(msg).stream().content();
    }
    @GetMapping("/stream/chatByQwenChatClient")
    public Flux<String> streamChatByQwenChatClient(@RequestParam("msg") String msg) {
        return qwenChatClient.prompt().user(msg).stream().content();
    }

}
